<?php
class ConfigHeartbeatModel extends Model{

    public $tableField = array (
        'id',
        'ip',
        'domain',
        'status',
        'send',
        'update_time',
    );

    public function getPrimaryKey(){
        return $this -> primaryKey = 'id';
    }

    public function getTableFields(){
        return $this -> tableField;
    }

    public function tableName(){
        return $this -> tableName = 't_config_heartbeat';
    }

    /**
     * @param $start
     * @param $end
     * @param string $where
     * @return array
     */
    public function getLists($start, $end, $where = "1=1" ){
        $result = $this -> getAll($where, null, array('*'), 'version desc', $start, $end);
        return $result;
    }

    /**
     * @param $post_value
     * @return bool
     */
    public function addData($post_value){
        $data = array();
        foreach($this->tableField as $row ){
            $data[$row] = $post_value[$row];
        }
        $data['update_time'] = time();
        return $this -> insert($data);
    }


    public function updateData($post_value,$map){
        $data['update_time'] = time();
        return $this->update($post_value,$map);
    }
}
